<?php
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/interfaces/IJobHistoryAccessDao.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/interfaces/IConnectionAccessDao.php';
	require_once $_SERVER['DOCUMENT_ROOT'] . '/SAGER/model/factory/ConnectionFactory.php';
	
	error_reporting (E_ALL ^ E_NOTICE);
	
	$debug = $_SESSION['debug'];

	class  MySqlJobHistoryAccessDao implements IJobHistoryAccessDao {
 		/**
		 * Constructor of the job history dao
		 */
	 	public function __construct () {}
	
		/**
		 * Creates a job history
		 */
		public function createJobHistory($jobHistory) {
			$pkStartDate = $jobHistory -> getPkStartDate();
			$endDate = $jobHistory -> getEndDate();
			$job = $jobHistory -> getJob();
			$salary = $jobHistory -> getSalary();
			$ci = $jobHistory -> getPkFkIdNumberEmployee();
			$departmentId = $jobHistory -> getPkFkIdDepartment();
			
			$connection = ConnectionFactory :: getMySqlConnectionAccessDao();
			$conn = $connection -> openConnection();
			
			$query = "INSERT INTO JOB_HISTORY VALUES ('$pkStartDate', '$endDate', '$job', 
				$salary, $ci, $departmentId)";
				
			$sentence = mysql_query($query, $conn);
			
			if ($sentence)
				return true;
			
			return false;
		}
	}
?>